<Query Kind="Program" />

void Main()
{
	IFactory factory1 = new Factory1();
	AbProductA productA1 = factory1.CreateProductA();
	AbProductB productB1 = factory1.CreateProductB();
	productA1.Method();
	productB1.Method();

	IFactory factory2 = new Factory2();
	AbProductA productA2 = factory2.CreateProductA();
	AbProductB productB2 = factory2.CreateProductB();
	productA2.Method();
	productB2.Method();
}

abstract class AbProductA{
	public abstract void Method();
}

abstract class AbProductB{
	public abstract void Method();
}

class ProductA1 : AbProductA
{
	public override void Method()
	{
		Console.WriteLine("这里是产品A1");
	}
}

class ProductA2 : AbProductA
{
	public override void Method()
	{
		Console.WriteLine("这里是产品A2");
	}
}

class ProductB1 : AbProductB
{
	public override void Method()
	{
		Console.WriteLine("这里是产品B1");
	}
}

class ProductB2 : AbProductB
{
	public override void Method()
	{
		Console.WriteLine("这里是产品B2");
	}
}

interface IFactory
{
	public AbProductA CreateProductA();
	public AbProductB CreateProductB();
}

class Factory1 : IFactory
{
	public AbProductA CreateProductA()
	{
		return new ProductA1();
	}

	public AbProductB CreateProductB()
	{
		return new ProductB1();
	}
}

class Factory2 : IFactory
{
	public AbProductA CreateProductA()
	{
		return new ProductA2();
	}

	public AbProductB CreateProductB()
	{
		return new ProductB2();
	}
}